import { Column, Entity, Index, PrimaryGeneratedColumn } from "typeorm";

@Index("idx_code", ["code"], {})
@Index("idx_status", ["status"], {})
@Index("idx_ishome", ["ishome"], {})
@Index("idx_isload", ["isload"], {})
@Entity("rrz_plugin", { schema: "rrzcms" })
export class RrzPlugin {
  @PrimaryGeneratedColumn({ type: "int", name: "id", unsigned: true })
  id: number;

  @Column("varchar", { name: "code", comment: "编码", length: 20 })
  code: string;

  @Column("varchar", { name: "name", comment: "名称", length: 50 })
  name: string;

  @Column("varchar", { name: "desc", comment: "描述", length: 255 })
  desc: string;

  @Column("varchar", { name: "version", comment: "版本号", length: 20 })
  version: string;

  @Column("varchar", { name: "author", comment: "作者", length: 30 })
  author: string;

  @Column("tinyint", {
    name: "isadmin",
    comment: "是否存在后台（0否1是）",
    width: 1,
    default: () => "'1'",
  })
  isadmin: boolean;

  @Column("tinyint", {
    name: "ishome",
    comment: "是否存在前台（0否1是）",
    width: 1,
    default: () => "'0'",
  })
  ishome: boolean;

  @Column("tinyint", {
    name: "isload",
    comment: "是否自动加载（0手动加载、1自动加载）",
    width: 1,
    default: () => "'0'",
  })
  isload: boolean;

  @Column("text", {
    name: "loadtemp",
    nullable: true,
    comment: "自动加载在指定模板，空白默认全部",
  })
  loadtemp: string | null;

  @Column("text", { name: "config", nullable: true, comment: "额外参数" })
  config: string | null;

  @Column("text", {
    name: "data",
    nullable: true,
    comment: "配置存储数据，简单插件可以不创建表",
  })
  data: string | null;

  @Column("varchar", {
    name: "saflag",
    nullable: true,
    comment: "标示内容",
    length: 500,
  })
  saflag: string | null;

  @Column("tinyint", {
    name: "status",
    comment: "状态（0未安装、1启用、2禁用）",
    width: 1,
    default: () => "'0'",
  })
  status: boolean;

  @Column("int", { name: "addtime", comment: "添加时间", default: () => "'0'" })
  addtime: number;

  @Column("int", { name: "sort", comment: "执行顺序", default: () => "'0'" })
  sort: number;
}
